/*
 * ScheduleRoute.java
 *
 * Created on October 5, 2007, 4:36 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package drb;

import java.util.ArrayList;

/**
 *
 * @author Asger
 */
public class ScheduleRoute {
    
    public ArrayList<TrainSchedule> schedules = new ArrayList<TrainSchedule>();
    
    /** Creates a new instance of ScheduleRoute */
    public ScheduleRoute() {
    }
    
    public int getId() {
        return schedules.get(0).id;
    }
    
    public int getDuration() {
        if (schedules.size() == 0)
            return 0;
        
        return (int)(schedules.get(schedules.size()-1).arrival - schedules.get(0).departure);
    }
    
    public String toString() {
        if (schedules.size() == 0)
            return "";
        
        TrainSchedule first = schedules.get(0);
        TrainSchedule last = schedules.get( schedules.size()-1 );
        
        String s = first.from;
        for (TrainSchedule schedule : schedules) {
            s += "-" + schedule.to;
        }
        s += " (at " + Command.formattedTime(first.departure) + " to " +Command.formattedTime(last.arrival) +", " +first.weekdays+")";
        
        return s;
    }
}












